package mvpfoot.entity;


import android.nfc.Tag;

import com.google.gson.annotations.SerializedName;

import java.io.File;
import java.io.Serializable;

import mvpfoot.utils.BaseUtil;
import okhttp3.internal.Util;

/**
 * Created by Chen qin lang on 2016/12/27.
 */
public class User implements Serializable {
    /**
     * @Fields: serialVersionUID
     */
    private static final long serialVersionUID = 1L;
    public String name;
    public long score;
    public boolean loginStatus;
    private final static String TAG="User";

    private User() {

    }

    public void savaObject() {
        BaseUtil.saveObject(Constant.CACHE_FILE+TAG,this);
    }
    private static User instance;

    public static User getInstance(){
        Object object = BaseUtil.restoreObject(Constant.CACHE_FILE+TAG);
        if (object==null){
            object=new User();
            BaseUtil.saveObject(Constant.CACHE_FILE+TAG,object);
        }
        instance= (User) object;
        return instance;
    }

    public static void reset(){
        instance.name=null;
        instance.loginStatus=false;
        instance.score=0;
        File file=new File(Constant.CACHE_FILE+TAG);
        if (file.isFile()){
            file.delete();
        }
    }
    public long getScore() {
        return score;
    }

    public void setScore(long score) {
        this.score = score;
    }

    public boolean getLoginStatus() {
        return loginStatus;
    }

    public void setLoginStatus(boolean loginStatus) {
        this.loginStatus = loginStatus;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
